home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0039 / source / dcpiccnv.def < prev    next >
Text File  |  1997-04-16  |  12KB  |  237 lines

  1. DEFINITION MODULE DCPicCnv;
  2.  
  3. (*---------------------------------------------------------------------*)
  4. (*   LOW LEVEL Picture Conversion Routines For DegasConvert            *)
  5. (*                                                                     *)
  6. (*   THESE ROUTINES ARE USED BY DegasCPC to PROCESS PICTURES.          *)
  7. (*                                                                     *)
  8. (*   The reason I choose to split the conversion routines is because   *)
  9. (*   the higher level routines need to access the screen to show the   *)
  10. (*   user what is happening. This way the low-level conversion         *)
  11. (*   module doesn't need to know about the screen, this hides          *)
  12. (*   implentation details.                                             *)
  13. (*                                                                     *)
  14. (*   Note: There are functions for each type of resolution, this is    *)
  15. (*         for efficiency reasons. Also for efficiency reasons there   *)
  16. (*         will be routines to convert ONE picture line. The picture   *)
  17. (*         to be operated on will be passed each time along with the   *)
  18. (*         print palette to go with it.                                *)
  19. (*                                                                     *)
  20. (*   The first version of this program was rather simple in the way it *)
  21. (*   allocated black and white patterns to the colours in the picture  *)
  22. (*   to be converted. Specifically, it just used the bits in the index *)
  23. (*   number of a pixel as the pattern to plot.( i.e. a dark colour may *)
  24. (*   come out light in the conversion ). A better way would be to look *)
  25. (*   at the colours in the palette and allocate a shade to it depending*)
  26. (*   on the intensity of the colour of the pixel. This is what is      *)
  27. (*   implemented in this version of the program.                       *)
  28. (*                                                                     *)
  29. (*   For a low-res picture there are 16 colours of different intensity *)
  30. (*   spread through the palette. I want to allocate print bit patterns *)
  31. (*   ( a number from 0 to 15 ) to each entry in the palette so that    *)
  32. (*   light colours print light and dark colours print dark. To         *)
  33. (*   simplify(!) this process I intend to sort the palette by          *)
  34. (*   intensity, allocate the print patterns to the palette in order    *)
  35. (*   of increasing number of on-bits in the print bit pattern.         *)
  36. (*                                                                     *)
  37. (*   Degas Picture Functions:                                          *)
  38. (*      1) Return the colour index of pixel                            *)
  39. (*      2) Return the Red,Green,Blue components of a palette entry     *)
  40. (*      3) Assign a print bit pattern,got from user,to a palette entry *)
  41. (*      4) Assign Default print bit patterns to the picture palette    *)
  42. (*      5) Return the print bit pattern for a pixel                    *)
  43. (*      6) Set a pixel in the hi-res picture                           *)
  44. (*      7) Clear all pixels in the hi-res picture                      *)
  45. (*                                                                     *)
  46. (*                                                                     *)
  47. (*                                                                     *)
  48. (*   Version 1.1      August 1987                    L.G.Miller        *)
  49. (*---------------------------------------------------------------------*)
  50.  
  51. FROM DCGlobal           IMPORT  DegasPicture,
  52.                                 Palette,
  53.                                 PrintPalette,
  54.                                 PrintBitPatternSet,
  55.                 LowRes16PixelsPtr,
  56.                 LowResScreenLinePtr,
  57.                 LowResScreen,
  58.                 MedRes16PixelsPtr,
  59.                     MedResScreenLinePtr,
  60.                 MedResScreen,
  61.                 HiRes16PixelsPtr,
  62.                     HiResScreenLinePtr,
  63.                 HiResScreen;
  64.  
  65. (* return address of pixel group and the bit number.
  66.    Note: The leftmost pixel is bit 0. This is due to the
  67.          way this compiler numbers bits in a bitset. *)
  68. PROCEDURE LowRes16PixelsAddr (     x, y : CARDINAL;
  69.                    VAR picture : LowResScreen;
  70.                    VAR PixelNo : CARDINAL;
  71.                    VAR PGPtr   : LowRes16PixelsPtr);
  72.  
  73. PROCEDURE MedRes16PixelsAddr (     x, y : CARDINAL;
  74.                    VAR picture : MedResScreen;
  75.                    VAR PixelNo : CARDINAL;
  76.                    VAR PGPtr   : MedRes16PixelsPtr);
  77.  
  78. PROCEDURE HiRes16PixelsAddr (     x, y : CARDINAL;
  79.                   VAR picture : HiResScreen;
  80.                   VAR PixelNo : CARDINAL;
  81.                   VAR PGPtr   : HiRes16PixelsPtr);
  82.  
  83.  
  84. (*----------------------------------------------------------------------*)
  85. (* Find out the Colour index of a low-res pixel.                        *)
  86. (*----------------------------------------------------------------------*)
  87. PROCEDURE QueryXYLowResPixelIndex( x, y : CARDINAL;
  88.                        Picture : DegasPicture ) : CARDINAL;
  89.  
  90.  
  91. (*----------------------------------------------------------------------*)
  92. (* Find out the Colour index of a low-res pixel.                        *)
  93. (*----------------------------------------------------------------------*)
  94. PROCEDURE QueryLowResPixelIndex( PixelNo : CARDINAL;
  95.                      PGPtr : LowRes16PixelsPtr ) : CARDINAL;
  96.  
  97.  
  98. (*----------------------------------------------------------------------*)
  99. (* Find out the red,green,blue components of a low-res pixel            *)
  100. (*----------------------------------------------------------------------*)
  101. PROCEDURE QueryLowResPixelColour ( PixelNo : CARDINAL;
  102.                        PGPtr   : LowRes16PixelsPtr;
  103.                                    VAR palette : Palette;
  104.                                    VAR red, green, blue : CARDINAL );
  105.  
  106.  
  107. (*----------------------------------------------------------------------*)
  108. (* Return the Print bit Pattern associated with the Low Res pixel.      *)
  109. (*----------------------------------------------------------------------*)
  110. PROCEDURE QueryLowResPixelPBPattern ( PixelNo : CARDINAL;
  111.                                       PGPtr   : LowRes16PixelsPtr;
  112.                                       VAR printpalette : PrintPalette;
  113.                                       VAR pbp     : PrintBitPatternSet );
  114.  
  115.  
  116. (*----------------------------------------------------------------------*)
  117. (* Medium resolution versions of the above                              *)
  118. (*----------------------------------------------------------------------*)
  119.  
  120.  
  121. (*----------------------------------------------------------------------*)
  122. (* Find out the Colour index of a med-res pixel.                        *)
  123. (*----------------------------------------------------------------------*)
  124. PROCEDURE QueryXYMedResPixelIndex( x, y : CARDINAL;
  125.                        Picture : DegasPicture ) : CARDINAL;
  126.  
  127.  
  128. (*----------------------------------------------------------------------*)
  129. (* Find out the Colour index of a low-res pixel.                        *)
  130. (*----------------------------------------------------------------------*)
  131. PROCEDURE QueryMedResPixelIndex  ( PixelNo : CARDINAL;
  132.                    PGPtr : MedRes16PixelsPtr ) : CARDINAL;
  133.  
  134.  
  135. (*----------------------------------------------------------------------*)
  136. (* Find out the red,green,blue components of a low-res pixel            *)
  137. (*----------------------------------------------------------------------*)
  138. PROCEDURE QueryMedResPixelColour (     PixelNo : CARDINAL;
  139.                        PGPtr : MedRes16PixelsPtr;
  140.                                    VAR palette : Palette;
  141.                                    VAR red, green, blue : CARDINAL );
  142.  
  143.  
  144. (*----------------------------------------------------------------------*)
  145. (* Return the Print bit Pattern associated with the Med Res pixel.      *)
  146. (*----------------------------------------------------------------------*)
  147. PROCEDURE QueryMedResPixelPBPattern (     PixelNo : CARDINAL;
  148.                           PGPtr : MedRes16PixelsPtr;
  149.                                       VAR printpalette : PrintPalette;
  150.                                       VAR pbp     : PrintBitPatternSet );
  151.  
  152.  
  153.  
  154. (*----------------------------------------------------------------------*)
  155. (* Assign a print bit pattern to a palette entry                        *)
  156. (*----------------------------------------------------------------------*)
  157. PROCEDURE SetPBPattern ( VAR printpalette : PrintPalette;
  158.                              colourindex  : CARDINAL;
  159.                              pbp          : PrintBitPatternSet );
  160.  
  161.  
  162. (*----------------------------------------------------------------------*)
  163. (* Find out the current print bit pattern for a palette entry           *)
  164. (*----------------------------------------------------------------------*)
  165. PROCEDURE QueryPBPattern ( VAR printpalette : PrintPalette;
  166.                                colourindex  : CARDINAL;
  167.                            VAR pbp          : PrintBitPatternSet );
  168.  
  169.  
  170.  
  171. (*----------------------------------------------------------------------*)
  172. (*----------------------------------------------------------------------*)
  173. (* Routines to process the output hi-res picture                        *)
  174. (*----------------------------------------------------------------------*)
  175. (*----------------------------------------------------------------------*)
  176.  
  177. (*----------------------------------------------------------------------*)
  178. (* Reset all the pixels in the output hi-res picture                    *)
  179. (*----------------------------------------------------------------------*)
  180. PROCEDURE ClearHiRes ( VAR screen : HiResScreen );
  181.  
  182.  
  183. (*----------------------------------------------------------------------*)
  184. (* Set on one hi-res pixel                                              *)
  185. (*----------------------------------------------------------------------*)
  186. PROCEDURE SetHiResPixel (     PixelNo : CARDINAL;
  187.                               PGPtr   : HiRes16PixelsPtr );
  188.  
  189.  
  190. (*----------------------------------------------------------------------*)
  191. (* This routine will plot the pattern in a square.                      *)
  192. (*----------------------------------------------------------------------*)
  193. PROCEDURE SetLowToHiResPBPattern (     x, y   : CARDINAL;
  194.                                    VAR screen : HiResScreen;
  195.                                        bpb    : PrintBitPatternSet );
  196.  
  197.  
  198. (*----------------------------------------------------------------------*)
  199. (* This routine will plot the pattern in a rectangle                    *)
  200. (*----------------------------------------------------------------------*)
  201. PROCEDURE SetMedToHiResPBPattern (     x, y   : CARDINAL;
  202.                                    VAR screen : HiResScreen;
  203.                                        pbp    : PrintBitPatternSet );
  204.  
  205.  
  206. (*----------------------------------------------------------------------*)
  207. (* Convert ONE line of input low-res picture to output hi-res picture.  *)
  208. (*----------------------------------------------------------------------*)
  209. PROCEDURE ConvertLowToHiResOneLine ( VAR inpic, outpic : DegasPicture;
  210.                                      VAR ppalette      : PrintPalette;
  211.                                          inlineno      : CARDINAL );
  212.  
  213.  
  214. (*----------------------------------------------------------------------*)
  215. (* Convert ONE line of input med-res picture to output hi-res picture   *)
  216. (*----------------------------------------------------------------------*)
  217. PROCEDURE ConvertMedToHiResOneLine ( VAR inpic, outpic : DegasPicture;
  218.                                      VAR ppalette      : PrintPalette;
  219.                                          inlineno      : CARDINAL );
  220.  
  221.  
  222. (*----------------------------------------------------------------------*)
  223. (* Sort print palette.                                                  *)
  224. (*----------------------------------------------------------------------*)
  225. PROCEDURE SortByColour( VAR ppalette      : PrintPalette;
  226.                             NumberOfItems : CARDINAL );
  227.  
  228.  
  229. PROCEDURE SortByIndex( VAR ppalette      : PrintPalette;
  230.                             NumberOfItems : CARDINAL );
  231.  
  232.  
  233.  
  234.  
  235. END DCPicCnv.
  236.  
  237.